/********************************************************************************
 *      Copyright:  (C) 2019 Wu Yujun<540726307@qq.com>
 *                  All rights reserved.
 *
 *       Filename:  mosq_demo.h
 *    Description:  This head file mosquitto connect mqtt server
 *
 *        Version:  1.0.0(2019年07月22日)
 *         Author:  Wu Yujun <540726307@qq.com>
 *      ChangeLog:  1, Release initial version on "2019年07月22日 09时41分12秒"
 *                 
 ********************************************************************************/
#ifndef _MOSQ_DEMO_
#define _MOSQ_DEMO_


#define     BUF_SIZE        256

#define DEFAULT_CLIENTID    "9806|securemode=3,signmethod=hmacsha1,timestamp=789|"
#define DEFAULT_USERNAME    "Ubuntu&a1R4lbARNLO"
#define DEFAULT_PASSWD      "cf312c24db26cd32f379a2f8d96fffcf002acf5d"
#define DEFAULT_PORT        1883
#define DEFAULT_HOSTNAME    "a1R4lbARNLO.iot-as-mqtt.cn-shanghai.aliyuncs.com"
#define DEFAULT_SUBTOPIC    "/sys/a1R4lbARNLO/Ubuntu/thing/service/property/set"
#define DEFAULT_PUBTOPIC    "/sys/a1R4lbARNLO/Ubuntu/thing/event/property/post"

/* Aliyun Mqtt publish json model */
#define DEFAULT_METHOD      "thing.service.property.set"
#define DEFAULT_JSONID      "972179654"
#define DEFAULT_IDENTIFIER  "Data"
#define DEFAULT_VERSION     "1.0.0"


#define KEEP_ALIVE          60

enum{
    TYPE_SUB ,
    TYPE_PUB
};


typedef struct _st_mqtt
{
    char    hostname[BUF_SIZE] ;
    int     port ;
    char    username[BUF_SIZE] ;
    char    passwd[BUF_SIZE] ;
    char    clientid[BUF_SIZE] ;
    char    topic[BUF_SIZE] ;

    char    method[BUF_SIZE] ;
    char    json_id[BUF_SIZE] ;
    char    identifier[BUF_SIZE] ;
    char    version[BUF_SIZE] ;


}st_mqtt;

int gain_mqtt_conf(char *ini_path,st_mqtt *mqtt, int type) ;
void set_mqtt_conf(char *ini_path,char *host,int port,char *id,char *user,char *passwd,char *topic) ;
void set_conf(char *ini_path, char *value, const char * entry) ;




#endif
